package com.jd.jdmall;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
/**
 * ClassName:JDApplication
 * Author   :伍碧林
 * Email    :wubilin@itcast.cn
 * Date     :2017/2/17 09:19
 * Description:
 */
public class JDApplication extends Application {
    // 定义一些全局的变量
    private static Context mContext; // 全局的上下文对象
    private static Handler mHandler; // 全局的handler
    private static int mainThreadID; // 主线程ID
    private static Thread mainThread; // 应用的主线程

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = getApplicationContext();
        mHandler = new Handler();
        mainThreadID = android.os.Process.myTid();
        mainThread = Thread.currentThread();  // 因为在application 中的线程绝对是主线程


    }

    public static Context getmContext() {
        return mContext;
    }

    public static void setmContext(Context mContext) {
        JDApplication.mContext = mContext;
    }

    public static Handler getmHandler() {
        return mHandler;
    }

    public static void setmHandler(Handler mHandler) {
        JDApplication.mHandler = mHandler;
    }

    public static int getMainThreadID() {
        return mainThreadID;
    }

    public static void setMainThreadID(int mainThreadID) {
        JDApplication.mainThreadID = mainThreadID;
    }

    public static Thread getMainThread() {
        return mainThread;
    }

    public static void setMainThread(Thread mainThread) {
        JDApplication.mainThread = mainThread;
    }
}
